﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AMatysiak.Methods;

namespace AMatysiakTest.Methods
{
    [TestClass]
    public class GetMonthsBetweenTest
    {
        [TestMethod]
        public void compareEqualDates()
        {
            DateTime dt1 = DateTime.Now;
            DateTime dt2 = DateTime.Now;

            Assert.AreEqual(0, dt1.GetMonthsBetween(dt2));
        }

        [TestMethod]
        public void compareDatesOfThisSameMonth()
        {
            DateTime dt1 = "2010-01-01".ToDate();
            DateTime dt2 = "2010-01-31".ToDate();

            Assert.AreEqual(0, dt1.GetMonthsBetween(dt2));
        }

        [TestMethod]
        public void compareDatesOfTwoNextMonths()
        {
            DateTime dt1 = "2010-01-01".ToDate();
            DateTime dt2 = "2010-02-01".ToDate();

            Assert.AreEqual(1, dt1.GetMonthsBetween(dt2));
        }

        [TestMethod]
        public void compareDatesOf30DaysDifference()
        {
            DateTime dt1 = "2010-01-02".ToDate();
            DateTime dt2 = "2010-02-01".ToDate();

            Assert.AreEqual(0, dt1.GetMonthsBetween(dt2));
        }

        [TestMethod]
        public void compareDatesOfYearDifference()
        {
            DateTime dt1 = "2010-01-01".ToDate();
            DateTime dt2 = "2011-01-01".ToDate();

            Assert.AreEqual(12, dt1.GetMonthsBetween(dt2));
        }
    }
}
